package com.poetize.plus.entity.dto;

import com.poetize.plus.entity.po.WebInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

/**
 * @Author zuosy
 * @Date 2024/3/30 8:49
 **/
public record WebInfoDTO(
        @Schema(description = "id")
        @NotNull(message = "id不能为空")
        Long id,

        @Schema(description = "网站名称")
        @NotBlank(message = "网站名称不能为空")
        String webName,

        @Schema(description = "网站信息")
        @NotBlank(message = "网站信息不能为空")
        String webTitle,

        @Schema(description = "页脚")
        @NotBlank(message = "页脚不能为空")
        String footer,

        @Schema(description = "看板娘消息")
        String waifuJson
) {
    /**
     * DTO转实体类
     *
     * @param webInfoDTO
     * @return
     */
    public static WebInfo convertDTO(WebInfoDTO webInfoDTO) {
        return new WebInfo(
                webInfoDTO.id,
                webInfoDTO.webName,
                webInfoDTO.webTitle,
                webInfoDTO.footer,
                webInfoDTO.waifuJson);
    }
}
